home *** CD-ROM | disk | FTP | other *** search
- Path: news.bridge.net!news
- From: David Byrden <100101.2547@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Negative array-index ?
- Date: 9 Jan 1996 05:49:21 GMT
- Organization: self-employed
- Message-ID: <4csvl1$9gg@news.bridge.net>
- References: <30E9430C.4371B326@suse.de>
- NNTP-Posting-Host: ppp-mia1-58.bridge.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
-
- Richard;
-
- >>I have been trying to code some signal processing algorithms in C++.
- >> For digital filters I need to access "negative" array-indices. It is
- >> no problem to code this in an array-class (Everything below 0 is 0).
- >> But the compiler always warns about an negative Index.
-
- I don't quite understand what's happening. If you want an array with
- negative indices, just point a pointer into the middle of it;
-
- int array[100] ;
- int* ptr = array + 50 ;
-
- ptr[-4] // a valid int
-
- Is this when your compiler gets snotty? If so, I guess that either
- there is nothing you can do about it, or else the compiler will have some
- means for you to selectively disable any desired warning message.
- Certainly, it is a compiler-specific problem.
-
- David
-
-
-